﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;

namespace FalionForm
{
    public partial class MainWindow 
    {
        Thread thread;
        public void ThreadRun(ThreadStart Prm, string Message = "")
        {
            thread = new Thread(new ParameterizedThreadStart(MulitThread));
            thread.IsBackground = true;
            thread.Start(Prm);
            IonView = Message;
        }
        string IonView;
        private void MulitThread(object Prm)
        {
            ThreadStart Ps = (ThreadStart)Prm;
            //启动提示窗口
            this.Dispatcher.Invoke(new Action(() =>
            {
                busyWindow = new BusyWindow();
                if (IonView != "")
                {
                    busyWindow.Message = IonView;
                }
                busyWindow.Show();
                this.IsEnabled = false;
            }));
            Ps();
            //关闭提示窗口
            this.Dispatcher.Invoke(new Action(() =>
            {
                busyWindow.Close();
                this.IsEnabled = true;
            }));
        }
    }
}
